package com.oa.common.config.exception;

import com.oa.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * @author Admin
 * @title: OaException
 * @projectName Cloud_OA_Office
 * @description: OaException
 * @date 2024/10/2 16:41
 */
@Data //自定义异常类  添加data注解 生成getter setter方法
public class OAException extends RuntimeException{
    private Integer code; //状态码
    private String msg; //异常信息
    public OAException(Integer code,String msg) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }
    /**
     * 接收枚举类型对象
     * @param resultCodeEnum
     */
    public OAException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMessage();
    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}
